package com.cx.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {

    private final Logger LOGGER = LoggerFactory.getLogger(LogAspect.class);

    @Pointcut("execution(* com.cx.controller.*.*(..))")
    public void pointCut(){

    }


    @Before(value = "pointCut()")
    public void before(JoinPoint joinPoint){
        LOGGER.debug( "方法- 开始->" + joinPoint.getSignature().getName());
    }


    @AfterReturning(value = "pointCut()", returning="object")
    public void afterReturning(Object object){
        LOGGER.debug("object->" + object);  // 执行方法的返回值
        LOGGER.debug( "方法- 执行结束");
    }

}
